package com.talang.surfing.batch.app;

import cn.hutool.extra.spring.SpringUtil;
import com.talang.surfing.batch.annotation.EnableSurfingBatch;
import com.talang.surfing.batch.app.controller.GoodController;
import com.talang.surfing.batch.controller.BaseBatchController;
import com.talang.surfing.batch.dto.TaskStat;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableSurfingBatch
@Slf4j
public class SurfingBatchStarterApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(SurfingBatchStarterApplication.class, args);
    }

    @Override
    public void run(String... args) {
        TaskStat taskStat = SpringUtil.getBean(GoodController.class).doBatch();
        log.info("任务:{},总数:{},成功:{},失败:{}", taskStat.getTaskName(), taskStat.getTotal(), taskStat.getSuccess(), taskStat.getFail());
    }
}
